home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-taskin.adb < prev    next >
Text File  |  1996-01-30  |  4KB  |  93 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                        S Y S T E M . T A S K I N G                       --
  6. --                                                                          --
  7. --                                  B o d y                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.5 $                             --
  10. --                                                                          --
  11. --       Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved        --
  12. --                                                                          --
  13. -- GNARL is free software; you can redistribute it  and/or modify it  under --
  14. -- terms  of  the  GNU  Library General Public License  as published by the --
  15. -- Free Software  Foundation;  either version 2, or (at  your  option)  any --
  16. -- later  version.  GNARL is distributed  in the hope that  it will be use- --
  17. -- ful, but but WITHOUT ANY WARRANTY;  without even the implied warranty of --
  18. -- MERCHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. -- eral Library Public License  for more details.  You should have received --
  20. -- a  copy of the GNU Library General Public License along with GNARL;  see --
  21. -- file COPYING.LIB.  If not,  write to the  Free Software Foundation,  675 --
  22. -- Mass Ave, Cambridge, MA 02139, USA.                                      --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. --  This package body has to be eliminated once the offset calulation for
  27. --  ATCB is done statically. Also, the temporary placement of queuing
  28. --  primitives has to move back to Tasking.Queuing. (compiler error) ???
  29.  
  30. with System.Task_Primitives;
  31. --  Used for,  Task_Primitives.TCB_Ptr,
  32. --             Task_Primitives.Self
  33.  
  34. with System.Storage_Elements;
  35. --  Used for,  Storage_Elements.Storage_Offset,
  36. --             Storage_Elements."-"
  37. --             Storage_Elements.Storage_Count
  38.  
  39. with System.Tasking.Utilities;
  40. --  Used for,  Utilities.Ada_Task_Control_Block;
  41.  
  42. with Unchecked_Conversion;
  43.  
  44. package body System.Tasking is
  45.  
  46.    function "-"
  47.      (A    : System.Address;
  48.       B    : System.Address)
  49.       return Storage_Elements.Storage_Offset
  50.    renames Storage_Elements."-";
  51.  
  52.    function "-"
  53.      (A    : System.Address;
  54.       I    : Storage_Elements.Storage_Offset)
  55.       return System.Address
  56.    renames Storage_Elements."-";
  57.  
  58.    function Get_LL_TCB_Offset return Storage_Elements.Storage_Count;
  59.  
  60.    LL_TCB_Offset : Storage_Elements.Storage_Count := Get_LL_TCB_Offset;
  61.  
  62.    function Address_To_Task_ID is new
  63.      Unchecked_Conversion (System.Address, Task_ID);
  64.  
  65.    function TCB_Ptr_To_Address is new
  66.      Unchecked_Conversion (Task_Primitives.TCB_Ptr, System.Address);
  67.  
  68.    -----------------------
  69.    -- Get_LL_TCB_Offset --
  70.    -----------------------
  71.  
  72.    function Get_LL_TCB_Offset return Storage_Elements.Storage_Count is
  73.       ATCB_Record : Utilities.Ada_Task_Control_Block (0);
  74.  
  75.    begin
  76.       return ATCB_Record.LL_TCB'Address - ATCB_Record'Address;
  77.    end Get_LL_TCB_Offset;
  78.  
  79.    ----------
  80.    -- Self --
  81.    ----------
  82.  
  83.    --  This is an INLINE_ONLY version of Self for use in the RTS.
  84.  
  85.    function Self return Task_ID is
  86.       S : Task_Primitives.TCB_Ptr := Task_Primitives.Self;
  87.  
  88.    begin
  89.       return Address_To_Task_ID (TCB_Ptr_To_Address (S) - LL_TCB_Offset);
  90.    end Self;
  91.  
  92. end System.Tasking;
  93.